!(function() {
 window.onload=function() {
     var Tag = function (name) {
         return document.getElementsByTagName(name);
     }
     var imgs = Tag('img');
     var divs = Tag('div');
     var width = divs[1].offsetWidth;
     var height = divs[1].offsetHeight;
     for (var i = 0; i < divs.length; i++) {
         if (imgs[i].offsetWidth > width || imgs[i].offsetHeight > height) {
             var select = imgs[i].offsetHeight > imgs[i].offsetWidth ? imgs[i].offsetHeight : imgs[i].offsetWidth;
             imgs[i].style.width = imgs[i].offsetWidth * 200 / select + 'px';
             imgs[i].style.marginTop = (height - imgs[i].offsetHeight) / 2 + 'px';
         }
     }
 }
})()